package com.mars.common.utils;

import com.google.common.collect.Lists;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;

import java.util.List;

public class Dozers {
	static Mapper mapper = DozerBeanMapperBuilder.create()
            .withMappingFiles("dozerBeanMapping.xml")
            .build();

    static <T, U> List<U> mappers(final List<T> source, final Class<U> destType) {
        final List<U> dest = Lists.newArrayList();
        for (T element : source) {
            dest.add(mapper.map(element, destType));
        }

        return dest;
    }
}
